package com.stadium.common.enums;

/**
 * @program: smartgame-rugby
 * @description:
 * @author: firstSeven
 * @create: 2020/01/17
 */
public enum ResultEnum {
    UNKNOWN_ERROR(500,"未知错误"),
    SUCCESS(200, "成功"),
    TOKEN_TIMEOUT(411, "token超时"),
    TOKEN__NOT_NULL(412, "token不能为空"),
    IDNOEXIST(501,"身份证号重复！"),
    IDNOILLEGAL(502,"身份证号不合法！"),
    PHONENUMEXIST(503,"手机号重复"),
    PHONENUMLLEGAL(504,"手机号不合法"),
    FILE_EXCEEDED_LIMIT(505,"文件大小超过限制"),
    FILE_TYPE_MISMATCH(506,"文件类型不匹配"),
    CODE_REPETITION(507,"组织code重复"),
    NAME_REPETITION(508,"名称code重复"),
    ASSOCIATIONUSER_EXIST(509,"组织内用户已存在"),
    LEAGUEUSER_EXIST(510,"联赛内裁判已存在"),
    NEEDDATA_NOTNULL(511,"必填数据不能为空"),
    PRINCIPALFORBID_DELETE(512,"负责人不可被删除"),
    PASSWORD_ERROR(513,"密码错误"),
    ACCOUNT_FORBIDDEN(514,"账号禁用"),
    ACCOUNT_NOTEXIST(515,"账号不存在"),
    LEAGUETEAM_EXIST(516,"联赛内队伍已存在"),
    FILE_NOT_NULL(517,"文件不能为空"),
    FORBIDDEN_DELETE(518,"禁止删除"),
    PARAMETER_ERROR(519,"参数错误"),
    TEAMS_NOT_ONE(520,"比赛主客场球队不能是一支球队"),
    ENDTIME_NEED_AFTER_STARTTIME(521,"结束时间需要在开始时间之后"),
    STARTTIME_NEED_AFTER_NOW(522,"比赛开始时间需要在现在时间之后"),
    NO_ACCESS(523,"无权限"),
    VALID(0, "有效数据"),
    INVALID(1,"无效数据");
    private Integer code;
    private String msg;

    ResultEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ResultEnum getMsgByCode(Integer code) {
        for (ResultEnum resultEnum : ResultEnum.values()) {
            if (code.equals(resultEnum.getCode())) {
                return resultEnum;
            }
        }
        return ResultEnum.UNKNOWN_ERROR;
    }

    public static ResultEnum getCodeByMsg(String msg) {
        for (ResultEnum resultEnum : ResultEnum.values()) {
            if (msg.equals(resultEnum.getMsg())) {
                return resultEnum;
            }
        }
        return ResultEnum.UNKNOWN_ERROR;
    }
}
